#include <stdio.h>
#include <string.h>
#include <stdlib.h>
 
#define MAX_LEN (256)
 
void inputString(const char * prompt, char * input)
{
        input[0] = 0;
        printf("%s", prompt);
        scanf("%[^\n]", input);
        fflush(stdin);
}
 
int files_comprasion_by_strings(char * line, char *line2)
{
        FILE * inFile = NULL, * inFile2 = NULL;
        int i = 0, j = -1;
        inFile = fopen(line, "r");
		inFile2 = fopen(line2, "r");
        line[0] = 0;
		line2[0] = 0;
        while ((!feof(inFile)&&(!feof(inFile2))))
        {
                fgets(line, MAX_LEN, inFile);
				fgets(line2, MAX_LEN, inFile2);
				if(strcmp(line, line2) == 0)
				{
					i++;
				}
				else
				{
					j=i;
					break;
				}
        }
		if(!strcmp(line, line2)) 
		{
			return 0;
		}
		else
		{
			return j+1;
		}
		fclose(inFile);
		fclose(inFile2);
}
void main()
{
	int g;
	char line[MAX_LEN] = "", line2[MAX_LEN]="";
	inputString("Input file #1 name: ", line);
	inputString("Input file #2 name: ", line2);
	g = files_comprasion_by_strings(line, line2);
	if(g==0)
		{
			printf("Files are same.\n");
			system("PAUSE");
		}
	else
		{
			printf("Difference between files #1 and #2 on string #%d.\n", g);
			system("PAUSE");
		}
}